//
//  TwoTabButView.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/18.
//

#import "TwoTabButView.h"

@implementation TwoTabButView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUI];
    }
    return self;
}

-(void)setUI
{
    
    self.lefttabbut = [[UIButton alloc]initWithFrame:CGRectMake(16, 10, (APPwidth-48)/2, 45)];
    self.lefttabbut.layer.cornerRadius = 45/2;
    self.lefttabbut.layer.masksToBounds = YES;
    self.lefttabbut.layer.borderWidth = 1;
    self.lefttabbut.layer.borderColor = rgba(22, 120, 255, 1).CGColor;
    self.lefttabbut.backgroundColor = [UIColor whiteColor];
    self.lefttabbut.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.lefttabbut setTitleColor:rgba(22, 120, 255, 1) forState:UIControlStateNormal];
    [self.lefttabbut addTarget:self action:@selector(tabbutCheng:) forControlEvents:UIControlEventTouchUpInside];
    self.lefttabbut.tag = 0;
    [self addSubview:self.lefttabbut];
    
    
    self.righttabbut = [[UIButton alloc]initWithFrame:CGRectMake(32+(APPwidth-48)/2, 10, (APPwidth-48)/2, 45)];
    self.righttabbut.layer.cornerRadius = 45/2;
    self.righttabbut.layer.masksToBounds = YES;
    self.righttabbut.backgroundColor = rgba(22, 120, 255, 1);
    self.righttabbut.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.righttabbut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.righttabbut addTarget:self action:@selector(tabbutCheng:) forControlEvents:UIControlEventTouchUpInside];
    self.righttabbut.tag = 1;
    [self addSubview:self.righttabbut];
    
}


-(void)tabbutCheng:(UIButton *)but
{
    if ([self.delegate respondsToSelector:@selector(TwoTabButViewBtnSelectedDelegate:)]) {
        [self.delegate TwoTabButViewBtnSelectedDelegate:but.tag];
    }
}

@end
